import 'package:flutter/material.dart';
import 'package:kxy_flutter_app/auth.dart';
import 'package:kxy_flutter_app/helper/http.dart';
import 'package:kxy_flutter_app/model/user_basic.dart';

class MyViewModel with ChangeNotifier {
  UserBasic _user = new UserBasic(realName: '', deptName: '', headUrl: '');
  UserBasic get user => _user;

  bool _isLoad = false;
  bool get isLoad => _isLoad;

  Future load() async {
    var res = await Http.instance.post(
      '/usercenter-app/user/userbasicinfo',
      params: {'userId': Auth.instance.userId},
    );
    _user = UserBasic.fromJson(res.data);
    _isLoad = true;
    notifyListeners();
  }

  void clear() {
    this._isLoad = false;
    this._user = new UserBasic(realName: '', deptName: '', headUrl: '');
  }
}
